package com.ham.mud.commands.skills;

import com.ham.mud.ServerConnection;
import com.ham.mud.Targetable;
import com.ham.mud.characters.MudCharacter;
import com.ham.mud.characters.Vitals;
import com.ham.mud.characters.player.Player;

import java.util.Random;

/**
 * Created by hlucas on Jun 27, 2011 at 1:19:25 PM
 */
public class KickSkill extends Skill {
    private static final int MOVE_COST = 3;
    public static final Random rand = new Random();

    @Override
    protected void useSkill(ServerConnection connection, Targetable targetable, ServerConnection enemy) {
        MudCharacter enemyPlayer = (MudCharacter) targetable;
        if(enemyPlayer == null) {
            connection.printSolo("Kick who?");
            return;
        }
        
        Player player = connection.getPlayer();
        Vitals vitals = player.getVitals();
        int move = vitals.getMove();
        if(move < MOVE_COST) {
            connection.println("You don't have enough energy to kick " + enemyPlayer.getName() + ".");
            return;
        } else {
            vitals.decrementMove(MOVE_COST);
        }

        int damageRoll = (rand.nextInt(connection.getPlayer().getLevel()) + 1) * 4;
        enemyPlayer.decrementHealth(damageRoll);
        connection.println("You kick " + enemyPlayer.getName() + " for " + damageRoll + " damage.");
        if(enemy != null) {
            enemy.println(player.getName() + " kicks you for " + damageRoll + " damage.");
        }
    }

    @Override
    public int getRounds() {
        return 2;
    }

    @Override
    protected String getCommandName() {
        return "kick";
    }

    @Override
    protected boolean isCombatSkill() {
        return false;
    }

    @Override
    public String getName() {
        return "Kick";
    }
}
